﻿//Szu
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;

namespace CharacterLibrary
{
    /// <summary>
    /// Klasa której metody skupiają się wokół obiektu zjadanego przez Pacmana.
    /// </summary>
    public class Ball : Character
    {
        
        private static string PATH_BALL = @"CINEMA4D/ball";
        private static string PATH_COIN = @"CINEMA4D/coin";
        public enum BallSize { Small = 0, Big };
        private float angleX, angleY;
        private float division;
        public BallSize size;
        public float Division
        {
            get
            {
                return division;
            }
        }

        public Ball(ContentManager content, GraphicsDeviceManager graphics, Global.PointType pointType, int x, int z, float division, BallSize size)
            : base(graphics, x, z)
        {
            this.division = division;
            this.size = size;
            switch (pointType)
            {
                case Global.PointType.Ball:
                    model = content.Load<Model>(PATH_BALL);
                    break;
                case Global.PointType.Coin:
                    model = content.Load<Model>(PATH_COIN);
                    break;
            }
            
            this.position = new Vector3(x, Global.ConstantVision.InitYObjectPosition, z);
            bornPlace = new Vector3(x, Global.ConstantVision.InitYObjectPosition, z);
        }
        public override void Draw()
        {
            angleX += Global.GameSettings.coinRotationXSpeed;
            angleY += Global.GameSettings.coinRotationYSpeed;
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World = Matrix.CreateScale(division, division, division) * Matrix.CreateRotationY(angleY) * Matrix.CreateRotationX(angleX) * Matrix.CreateTranslation(position);
                    effect.View = Global.Vision.view;
                    effect.Projection = Global.Vision.projection;
                    effect.EnableDefaultLighting();
                }
                mesh.Draw();
            }
        }

    }
}
